import { codeInspectorPlugin } from 'code-inspector-plugin'

export default defineNuxtConfig({
  ssr: false,
  compatibilityDate: '2024-11-01',
  devtools: { enabled: true },
  pages: true,
  devServer: {
    port: 3888,
  },
  nitro: {
    preset: 'static',
    devProxy: {
      '/api': {
        target: 'https://a79163.com', // a01 https://a01.168pn.com
        changeOrigin: true,
        autoRewrite: true,
      },
    },
  },

  modules: [
    '@nuxtjs/i18n',
    '@nuxt/eslint',
    '@nuxt/fonts',
    '@nuxt/icon',
    '@nuxt/image',
    '@nuxt/scripts',
    '@nuxt/test-utils',
    '@nuxt/ui',
    '@vueuse/nuxt',
    '@pinia/nuxt',
  ],
  image: {
    dir: 'public/images',
    alias: {
      png: '/images/png',
      webp: '/images/webp',
      icons: '/images/icons',
    },
  },
  icon: {
    mode: 'svg',
    customCollections: [
      {
        prefix: 'icon',
        dir: './assets/icons',
      },
    ],
    clientBundle: {
      sizeLimitKb: 1024,
    },
  },
  components: {
    global: true,
    dirs: ['~/components'],
  },
  imports: {
    // Auto-import pinia stores defined in `~/stores`
    dirs: ['stores', 'types', 'apis', 'utils'],
    presets: [
      {
        from: 'lodash-es',
        imports: ['debounce', 'floor', 'throttle', 'cloneDeep', 'uniqBy', 'uniq', 'flatten', 'xor', 'isArray'],
      },
      {
        from: 'vue-request',
        imports: ['useRequest'],
      },
      {
        from: 'dayjs',
        imports: ['dayjs'],
      },
    ],
  },

  i18n: {
    locales: [
      { code: 'en', name: '英语', file: 'en-US.yml' },
      { code: 'hi', name: '印地语', file: 'hi-IN.yml' },
      { code: 'in', name: '印度尼西亚语', file: 'in-ID.yml' },
      { code: 'ja', name: '日语', file: 'ja-JP.yml' },
      { code: 'ko', name: '韩语', file: 'ko-KR.yml' },
      { code: 'pt', name: '葡萄牙语', file: 'pt-BR.yml' },
      { code: 'th', name: '泰语', file: 'th-TH.yml' },
      { code: 'vi', name: '越南语', file: 'vi-VN.yml' },
      { code: 'zh', name: '中文', file: 'zh-CN.yml' },
    ],
    lazy: true,
    // langDir: 'locales',
    defaultDirection: 'ltr',
    defaultLocale: 'zh',
    strategy: 'prefix',
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected',
      redirectOn: 'root',
      alwaysRedirect: true,
    },
  },

  css: ['~/assets/css/main.css'],
  app: {
    pageTransition: { name: 'page' },
  },
  vite: {
    plugins: [codeInspectorPlugin({ bundler: 'vite' })],
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "./assets/css/mixin.scss";`,
        },
      },
    },
  },
  // buildDir: 'dist'
})
